package org.tloss.web.editor.model.oper.math;

import org.tloss.web.editor.model.FormField;
import org.tloss.web.editor.utils.Constants;

public class FormFieldOperand extends MathOperand {
	private FormField formField;

	public FormField getFormField() {
		return formField;
	}

	public void setFormField(FormField formField) {
		this.formField = formField;
	}

	@Override
	public String getDisplayText() {
		if (formField != null) {
			return "Form[" + formField.getName()+"]";
		} else {
			return "Form[]";
		}
	}

	@Override
	public String generate(int type, Object[] param) {
		if(type ==  Constants.CodeType.JAVA){
			return "form.get"+formField.getName()+"()";
		}
		return null;
	}

	@Override
	public String getType() {
		return formField.getMappingType();
	}

}
